import requests
from lxml import etree

url = "http://www.xiangpi.com/shiti/231564.html"
headers = {
    "Accept-Language": "zh-CN,zh",
    "Cache-Control": "max-age=0",
    "Connection": "keep-alive",
    "Host": "www.xiangpi.com",
    "Referer": "http://www.xiangpi.com/zujuan/3",
    "Upgrade-Insecure-Requests": "1",
    "User-Agent": "Mozilla/5.0 (X11;Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)Chrome/66.0.3359.117 Safari/537.36"
}

cookies = {"UM_distinctid": "162d34d934d672-0a7ba243b976d8-3b7c015b-1fa400-162d34d934f616", "pgv_pvid": "2267055979",
           "CNZZDATA1257100452": "1045295576-1523962166-http%253A%252F%252Fwww.xiangpi.com%252F%7C1524044650"}

respon = requests.get(url, headers=headers, cookies=cookies)

html = etree.HTML(respon.content.decode())
tests = html.xpath("//div[@class='content clearfix']//text()")

with open("./test.txt", "a") as f:
    for test in tests:
        f.writelines(test.strip()+"\n")
